<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
  xmlns:widget="http://www.netvibes.com/ns/">
  <head>
 
    <meta name="author" content="Doug Bromley" />
    <meta name="author_email" content="doug.bromley+netvibes@gmail.com" />
    <meta name="description" content="Search for cheap Flights at Lastminute.com" />
 
    <meta name="apiVersion" content="1.0" />
    <meta name="autoRefresh" content="30" />
    <meta name="debugMode" content="false" />
    <meta name="screenshot" content="http://www.straw-dogs.co.uk/netvibes/lastminuteflights/screenshot.gif" />
    <meta name="thumbnail" content="http://www.straw-dogs.co.uk/netvibes/lastminuteflights/thumbnail.gif" />
 
    <link rel="stylesheet" type="text/css" 
      href="http://www.netvibes.com/themes/uwa/style.css" />
    <script type="text/javascript" 
      src="http://www.netvibes.com/js/UWA/load.js.php?env=Standalone"></script>
 
    <title>Lastminute.com Flight Search</title>
    <link rel="icon" type="image/png" 
      href="http://www.lastminute.com/favicon.ico" />
 
<!-- Add your UWA preferences as needed -->
    <widget:preferences>
      <preference name="from" type="hidden" defaultValue="JFK" />
      <preference name="to" type="hidden" defaultValue="SFO" />
    </widget:preferences>
 
    <style type="text/css">
      .b-message {
      	border: 1px solid #d9ce6f;
      	background: #fdef75;
      	color: #7b6c45;
      	padding: 2px 5px;
      	margin: 5px 3px;
      }
      .b-message .close {
      	float: right;
      }
      .b-top {
      	padding: 10px;
      	font-size: 12px;
      	line-height: 1.0em;
      }
      
      .b-top input.people {
        width:20px;
        margin-left:10px;
        margin-right:10px;
      }
      
      .b-top table th {
      	text-align: left;
      	padding: 0 5px;
      }
      .b-calendar {
      	margin: 5px;
      	border: 1px solid #888;
      	padding: 1px;
      }
      
      td {
        padding:5px;
      }
      
      th {
        text-align:left;
      }
      
      .b-footer {
      	text-align: right;
      	padding: 0 15px 2px 15px;
      	height: 15px;
      	font-size: 10px;
      }
    </style>
 
    <script type="text/javascript">
// this is just some sample code
// you should delete it all to place your own code instead
 
      // this is how you would declare a global JS object
      var LastMinuteFlights = {};
 
      // this is how you would declare a global JS variable
      LastMinuteFlights.yourVariable = "My value";
      LastMinuteFlights.departureCities = {
    		"LON": {"title": "London - all airports"},
				"OTH": {"title": "Non UK airports"},
				"ABZ": {"title": "Aberdeen"},
				"BFS": {"title": "Belfast Int."},
				"BHD": {"title": "Belfast City Apt"},
				"BHX": {"title": "Birmingham Int."},
				"BLK": {"title": "Blackpool"},
				"BOH": {"title": "Bournemouth"},
				"BRS": {"title": "Bristol"},
				"CBG": {"title": "Cambridge"},
				"CWL": {"title": "Cardiff"},
				"CVT": {"title": "Coventry"},
				"DSA": {"title": "Doncaster"},
				"DND": {"title": "Dundee"},
				"EDI": {"title": "Edinburgh"},
				"EMA": {"title": "East Midlands"},
				"EXT": {"title": "Exeter"},
				"GCI": {"title": "Guernsey"},
				"GLA": {"title": "Glasgow Int."},
				"HUY": {"title": "Humberside"},
				"INV": {"title": "Inverness"},
				"IOM": {"title": "Isle of Man"},
				"JER": {"title": "Jersey"},
				"MSE": {"title": "Kent Int."},
				"LBA": {"title": "Leeds Bradford"},
				"LCY": {"title": "London City"},
				"LDY": {"title": "Londonderry"},
				"LON": {"title": "London"},
				"LGW": {"title": "London Gatwick"},
				"LHR": {"title": "London Heathrow"},
				"LTN": {"title": "London Luton"},
				"STN": {"title": "London Stansted"},
				"LPL": {"title": "Liverpool"},
				"MAN": {"title": "Manchester Int."},
				"MME": {"title": "Teesside"},
				"NCL": {"title": "Newcastle"},
				"NQY": {"title": "Newquay"},
				"NWI": {"title": "Norwich"},
				"PLH": {"title": "Plymouth"},
				"PIK": {"title": "Prestwick"},
				"SDZ": {"title": "Shetland Islands"},
				"SOU": {"title": "Southampton"}
      };
      
      LastMinuteFlights.departureMonths = [
        _("January"), 
        _("February"), 
        _("March"), 
        _("April"), 
        _("May"), 
        _("June"), 
        _("July"), 
        _("August"), 
        _("September"), 
        _("October"), 
        _("November"), 
        _("December")
      ];
      
      LastMinuteFlights.blocks = {};
      
      /**
       * Simple function for adding a header cell to a row
       * @param string title The text to appear in the cell
       * @param object row The widget object that the header cell is attached too
       */
      LastMinuteFlights.addHeaderCell = function(title, row){
        var hcell = widget.createElement('th');
	      hcell.setText(_(title));
	      row.appendChild(hcell);
      }
      
      LastMinuteFlights.addDataCell = function(content, row){
        var dcell = widget.createElement('td');
		    dcell.appendChild(content);
		    row.appendChild(dcell);
      }
      
      /**
       * Lastminute.com requires a load of hidden form fields to be sent. These are they!
       * @param object form The form object to append the hidden fields too.
       */
      LastMinuteFlights.addHiddenFormFields = function(form){
        form.appendChild(widget.createElement('input', {'type': 'hidden', 'name': 'skin', 'value': 'engb.lastminute.com'}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPCAT", 'value':""}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"TRANS", 'value':"ViewTransportationSearchBox,doSearchForTransportation"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPSAC", 'value':"LMZ"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPDCC", 'value':"GBP"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPCID", 'value':"0"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPFIT", 'value':""}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPSRT", 'value':"TA"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPHSI", 'value':"0"}));
  
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPHEI", 'value':"2"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPFSI", 'value':"0"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPFEI", 'value':"9"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPSFT", 'value':""}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPLOC", 'value':"en_GB"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPPID", 'value':"0"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPTRT", 'value':""}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPDES", 'id':"DPDES", 'value':""}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"mondial_auto", 'value':"true"}));
  
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"failureURL", 'value':"http://www.lastminute.com/site/travel/flights/flights-search-error.html"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"successURL", 'value':"/travel/flights/transport-results.html"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPXIN", 'value':"T"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPXCH", 'value':"T"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPXTR", 'value':"F"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPXCP", 'value':"F"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPXAL", 'value':"T"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPXMG", 'value':"T"}));
  			
  			// Making infants 0
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPNOI", 'value':"0"}));
  			
  			// Making class not care
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPCLS", 'value':"X"}));
  			
  			// Making ticket type return
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DP1WF", 'value':"0"}));
  			
  			// Making times "anytime"
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPIDT", 'value':"0001"}));
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name':"DPODT", 'value':"0001"}));
  			
  			// Making the carrier selection default to 'dont care'
  			form.appendChild(widget.createElement('input', {'type': 'hidden', 'name': "DPAIR", 'id':"carrier", 'value':"NONE"}));
  			
  			form.appendChild(widget.createElement('input', {'type':"hidden", 'name':"aid", 'value':"10424274"}));
        form.appendChild(widget.createElement('input', {'type':"hidden", 'name':"pid", 'value':"3150957"}));
        form.appendChild(widget.createElement('input', {'type':"hidden", 'name':"url", 'value':"http://www.lastminute.com/site/travel/flights/interstitial_page.html"}));
      }
 
      LastMinuteFlights.submitForm = function(){
        var p = UWA.$element(LastMinuteFlights.blocks.top);
        var formElements = document.lmfForm.elements;
        var qString = '?';
        for (el in formElements) {
          if(formElements[el].name != undefined && formElements[el].value != undefined){
            qString += formElements[el].name + '=' + formElements[el].value + '&';
          }
        }
        widget.openURL('http://www.tkqlhce.com/interactive' + qString);
      }
      
      // widget.onLoad is the first method called,
      // nothing can be done without it,
      // the rest of the code must be triggered from here - not <body onload="">.
      widget.onLoad = function() {
        widget.log('LastMinuteFlights.onLoad');
	      widget.body.setStyle('padding', '0');
	      widget.body.setStyle('margin', '0');
        /**
         * Setting up the widgets structure
         * Using Netvibes Expedia code as a template - Thank you Netvibes!!
         */
        widget.setBody('');
      	LastMinuteFlights.blocks.top     = widget.createElement('div', {'class': 'b-top'}); widget.body.appendChild(LastMinuteFlights.blocks.top);
      	LastMinuteFlights.blocks.footer  = widget.createElement('div', {'class': 'b-footer'}); widget.body.appendChild(LastMinuteFlights.blocks.footer);
        
      	// Create select boxes
      	LastMinuteFlights.departSelect  = widget.createElement('select', {'name': 'DPDAP'});
      	LastMinuteFlights.dateSelect    = widget.createElement('select', {'name': 'date_out_day'});
      	LastMinuteFlights.monthSelect   = widget.createElement('select', {'name': 'date_out_month'});
      	LastMinuteFlights.dateSelectIn  = widget.createElement('select', {'name': 'date_in_day'});
      	LastMinuteFlights.monthSelectIn = widget.createElement('select', {'name': 'date_in_month'});
      	
      	LastMinuteFlights.blocks.top.setHTML('');
      	var form  = widget.createElement('form', {'name': 'lmfForm'});
        var table = widget.createElement('table');
	      var tbody = widget.createElement("tbody");
	      
	      //*** !!!!! Start Departure Row !!!!! ***//
	      // Build header row
	      LastMinuteFlights.headerRowDep = widget.createElement('tr');	      
	      LastMinuteFlights.addHeaderCell('Departure', LastMinuteFlights.headerRowDep);
	      LastMinuteFlights.addHeaderCell('Date', LastMinuteFlights.headerRowDep);
	      LastMinuteFlights.addHeaderCell('Month', LastMinuteFlights.headerRowDep);	      
	      // Add header row to table body
	      tbody.appendChild(LastMinuteFlights.headerRowDep);
	      
	      // Build data row
	      LastMinuteFlights.dataRowDep = widget.createElement('tr');		    
		    LastMinuteFlights.addDataCell(LastMinuteFlights.departSelect, LastMinuteFlights.dataRowDep);
		    LastMinuteFlights.addDataCell(LastMinuteFlights.dateSelect, LastMinuteFlights.dataRowDep);
		    LastMinuteFlights.addDataCell(LastMinuteFlights.monthSelect, LastMinuteFlights.dataRowDep);
		    // Add data row to table body
		    tbody.appendChild(LastMinuteFlights.dataRowDep);
		    //*** !!!!! Finished Departure Row !!!!! ***//
		    
		    //*** !!!!! Start Destination Row !!!!! ***//
		    // Building the destination header row
		    LastMinuteFlights.headerRowDes = widget.createElement('tr');
	      LastMinuteFlights.addHeaderCell('Destination', LastMinuteFlights.headerRowDes);
	      LastMinuteFlights.addHeaderCell('Date', LastMinuteFlights.headerRowDes);
	      LastMinuteFlights.addHeaderCell('Month', LastMinuteFlights.headerRowDes);
	      // Add header row to table body
	      tbody.appendChild(LastMinuteFlights.headerRowDes);
	      
	      // Build data row
	      LastMinuteFlights.dataRowDes = widget.createElement('tr');
	      LastMinuteFlights.addDataCell(widget.createElement('input', {'name': 'DPAAP'}), LastMinuteFlights.dataRowDes);
	      LastMinuteFlights.addDataCell(LastMinuteFlights.dateSelectIn, LastMinuteFlights.dataRowDes);
	      LastMinuteFlights.addDataCell(LastMinuteFlights.monthSelectIn, LastMinuteFlights.dataRowDes);
		    
		    tbody.appendChild(LastMinuteFlights.dataRowDes);
		    //*** !!!!! Finished Destination Row !!!!! ***//
		    		    
		    // !!!!! Start People Row !!!!!
		    // Building the people header row
		    LastMinuteFlights.headerRowPeop = widget.createElement('tr');
		    peopleHeader = widget.createElement('th', {'colspan': '3'});
		    peopleHeader.setText('Adults / Children / Seniors');
	      LastMinuteFlights.headerRowPeop.appendChild(peopleHeader);

	      // Add header row to table body
	      tbody.appendChild(LastMinuteFlights.headerRowPeop);
	      
	      // Build data row
	      LastMinuteFlights.dataRowPeop = widget.createElement('tr');
	      var dcell = widget.createElement('td', {'colspan': '3'});
		    dcell.appendChild(widget.createElement('input', {'name': 'DPNOA', 'value': '1', 'class': 'people'}));
		    LastMinuteFlights.dataRowPeop.appendChild(dcell);
		    
		    //var dcell = widget.createElement('td');
		    dcell.appendChild(widget.createElement('input', {'name': 'DPNOC', 'value': '0', 'class': 'people'}));
		    LastMinuteFlights.dataRowPeop.appendChild(dcell);
		    
		    //var dcell = widget.createElement('td');
		    dcell.appendChild(widget.createElement('input', {'name': 'DPNOS', 'value': '0', 'class': 'people'}));
		    LastMinuteFlights.dataRowPeop.appendChild(dcell);
		    
		    tbody.appendChild(LastMinuteFlights.dataRowPeop);
		    // !!!!! Finished People Row !!!!!
		    
		    
		    // Build submit button row span
		    LastMinuteFlights.submitRow = widget.createElement('tr');
		    var scell = widget.createElement('td', {'colspan': '3'});
		    scell.appendChild(
		      widget.createElement(
		        'img', {'type': 'image', 'src': "http://www.lastminute.com/lmn/banner/uk/affiliates2006/searchboxes/search.gif", 'alt': 'Search', 'id':"flights_submit", 'onclick':'LastMinuteFlights.submitForm()'}
	        )
	      );
	      LastMinuteFlights.submitRow.appendChild(scell);
	      tbody.appendChild(LastMinuteFlights.submitRow);
		    
	      
		    table.appendChild(tbody);
		    
		    form.appendChild(table);
		    LastMinuteFlights.addHiddenFormFields(form);
		    
		    // Put form into top div
	      LastMinuteFlights.blocks.top.appendChild(form);      
        
	      // Build city departure select box
      	for(cityCode in LastMinuteFlights.departureCities) {
      		var option = widget.createElement('option', {'value': cityCode});
      		option.setText(LastMinuteFlights.departureCities[cityCode].title);
      		if (widget.getValue('from') == cityCode) { option.selected = true; }
      		LastMinuteFlights.departSelect.appendChild(option);
        }
        
        for (var i=1;i<32;i++) {
          var option = widget.createElement('option', {'value': i});
          option.setText(i);
          LastMinuteFlights.dateSelect.appendChild(option);
        }
        
        for (var x=0;x<12;x++) {
          month = LastMinuteFlights.departureMonths[x];
          var option = widget.createElement('option', {'value': x+1})
          option.setText(month);
          LastMinuteFlights.monthSelect.appendChild(option);
        }
        
        for (var x=0;x<12;x++) {
          month = LastMinuteFlights.departureMonths[x];
          var option = widget.createElement('option', {'value': x+1})
          option.setText(month);
          LastMinuteFlights.monthSelectIn.appendChild(option);
        }
        
        for (var i=1;i<32;i++) {
          var option = widget.createElement('option', {'value': i});
          option.setText(i);
          LastMinuteFlights.dateSelectIn.appendChild(option);
        }
      }
      
      widget.onRefresh = widget.onLoad;
    </script>
  </head>
  <body>
    <p>Loading...</p>
  </body>
</html>